﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Husb.Framework;
using Husb.Framework.DataAccess;

namespace Crawler.Model
{
    /// <summary>
    /// WebPageInfo Object
    /// <para>Summary description for WebPageInfo.<see cref="WebPageInfo" /></para>
    /// <para></para>
    /// <remarks></remarks>
    /// </summary>
    [Serializable]
    public partial class WebPageInfo : EntityBase
    {
        #region Private Variables
        private System.Guid id;
        private System.String name;
        private System.Guid categoryId;
        private System.String category;
        private System.String url;
        private System.String contentText;
        private System.Byte[] contentHTML;
        private System.DateTime? createdDate;
        private System.DateTime? createdDateEnd;
        private System.String tags;
        #endregion

        #region Constructors
        /// <summary>
        /// default Constructor
        /// <remarks>default Constructor</remarks>
        /// </summary>
        public WebPageInfo()
        {

        }
        /*
        /// <summary>
        /// <para></para>
        /// <param name="id"></param>
        /// <remarks></remarks>
        /// </summary>
        public WebPageInfo(System.Guid id)
            : base(id)
        {

        }

        /// <summary>
        /// Create a <see cref="WebPageInfo" /> Instance, and populate default value.
        /// <para></para>
        /// <param name="populateDefaultValue">populate default value or not</para>
        /// <remarks></remarks>
        /// </summary>
        public WebPageInfo(bool populateDefaultValue)
            : base(populateDefaultValue)
        {
            if (populateDefaultValue)
            {
                this.name = "";
                this.categoryId = Guid.Empty;
                this.category = "";
                this.url = "";
                this.contentText = "";
                this.contentHTML = new byte[] { };
                this.createdDate = DateTime.MinValue;
                this.tags = "";
            }
        }
        /// <summary>
        /// Create a <see cref="WebPageInfo" /> Instance, and populate default value.
        /// <para></para>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="categoryId"></param>
        /// <param name="category"></param>
        /// <param name="url"></param>
        /// <param name="contentText"></param>
        /// <param name="contentHTML"></param>
        /// <param name="createdDate"></param>
        /// <param name="tags"></param>
        /// <remarks></remarks>
        /// </summary>
        public WebPageInfo(
            System.Guid id,
            System.String name,
            System.Guid categoryId,
            System.String category,
            System.String url,
            System.String contentText,
            System.Byte[] contentHTML,
            System.DateTime? createdDate,
            System.String tags
        )
            : base(id, isDeleted, isActive, createdTime, createdBy, modifiedTime, lastModifiedBy, version, "")
        {
            this.name = name;
            this.categoryId = categoryId;
            this.category = category;
            this.url = url;
            this.contentText = contentText;
            this.contentHTML = contentHTML;
            this.createdDate = createdDate;
            this.tags = tags;

        }
         * */
        #endregion

        #region Properties
        /// <summary>
        /// 
        /// </summary>		
        public System.Guid Id
        {
            get { return id; }
            set { id = value; }
        }
        /// <summary>
        /// 
        /// </summary>		
        public System.String Name
        {
            get { return name; }
            set { name = value; }
        }
        /// <summary>
        /// 
        /// </summary>		
        public System.Guid CategoryId
        {
            get { return categoryId; }
            set { categoryId = value; }
        }
        /// <summary>
        /// 
        /// </summary>		
        public System.String Category
        {
            get { return category; }
            set { category = value; }
        }
        /// <summary>
        /// 
        /// </summary>		
        public System.String Url
        {
            get { return url; }
            set { url = value; }
        }
        /// <summary>
        /// 
        /// </summary>		
        public System.String ContentText
        {
            get { return contentText; }
            set { contentText = value; }
        }
        /// <summary>
        /// 
        /// </summary>		
        public System.Byte[] ContentHTML
        {
            get { return contentHTML; }
            set { contentHTML = value; }
        }
        /// <summary>
        /// 
        /// </summary>		
        public System.DateTime? CreatedDate
        {
            get { return createdDate; }
            set { createdDate = value; }
        }

        /// <summary>
        /// 
        /// </summary>		
        public System.DateTime? CreatedDateEnd
        {
            get { return createdDateEnd; }
            set { createdDateEnd = value; }
        }
        /// <summary>
        /// 
        /// </summary>		
        public System.String Tags
        {
            get { return tags; }
            set { tags = value; }
        }
        #endregion

        #region GenerateFilterExpression
        /// <summary>
        /// 产生组合查询的条件
        /// </summary>
        /// <param name="webPage">当前实体类<see cref="WebPageInfo"/>WebPageInfo</param>
        /// <returns></returns>
        public override string FilterExpression
        {
            get
            {
                string where = "";
                where += DataAccessHelper.GetPartWhereCondition("Id", Id);
                where += DataAccessHelper.GetPartWhereCondition("Name", Name);
                where += DataAccessHelper.GetPartWhereCondition("CategoryId", CategoryId);
                where += DataAccessHelper.GetPartWhereCondition("Category", Category);
                where += DataAccessHelper.GetPartWhereCondition("Url", Url);
                where += DataAccessHelper.GetPartWhereCondition("ContentText", ContentText);
                //where += DataAccessHelper.GetPartWhereCondition("ContentHTML", ContentHTML);
                where += DataAccessHelper.GetPartWhereCondition("CreatedDate", CreatedDate, CreatedDateEnd);
                where += DataAccessHelper.GetPartWhereCondition("Tags", Tags);

                return where;
            }
        }
        #endregion

        #region Validate
        /// <summary>
        /// 数据验证
        /// </summary> 
        protected override void Validate()
        {
            //AddRule("Price", "Price must be greater than or equal to 0", this.Price < 0);
            //AddRule("Name", "Name must be set", string.IsNullOrEmpty(this.Name));
        }
        #endregion
    }
}
